package com.newsee.remote.common.enumeration;

/**
 *  返回值 Code
 *  @author liangzhichen
 */
public enum ResponseCode {

    /**无**/
    NULL(-1),

    /**成功响应**/
    OK(200),

    /**权限不足**/
    UNAUTHORIZED(300),

    /**失败**/
    FAIL(400),

    /**格式错误**/
    FORMAT_ERROR(401),

    /**
     * 业务异常
     **/
    SERVICE_ERROR(500),

    /**重定向**/
    REDIRECT(302);

    private int code;

    ResponseCode(int code) {
        this.code = code;
    }

    public static ResponseCode genEnum(int code) {
        for (ResponseCode item: ResponseCode.values()) {
            if (item.getCode() == code) {
                return item;
            }
        }
        return NULL;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
